import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
  { path: "/", redirect: "/layout" },
  {
    path: "/layout",
    name: "layout",
    component: () => import("@/views/HmLayout.vue"),
    children: [
      {
        path: "article",
        component: () => import("@/views/layout/HmArticle.vue"),
        children: [
          { path: "", redirect: "recommend" },
          {
            path: "new",
            component: () => import("@/views/layout/NewArticle.vue"),
          },
          {
            path: "recommend",
            component: () => import("@/views/layout/RecommendArticle.vue"),
          },
        ],
      },
      {
        path: "collect",
        component: () => import("@/views/layout/HmCollect.vue"),
      },
      {
        path: "like",
        component: () => import("@/views/layout/HmLike.vue"),
      },
      {
        path: "my",
        component: () => import("@/views/layout/HmMy.vue"),
      },
    ],
  },
  {
    path: "/login",
    component: () => import("@/views/HmLogin.vue"),
  },
  {
    path: "/register",
    component: () => import("@/views/HmRegister.vue"),
  },
  {
    path: "/detail",
    component: () => import("@/views/HmDetail.vue"),
  },
  {
    path: "*",
    component: () => import("@/views/NotFind.vue"),
  },
];

const router = new VueRouter({
  mode: "history",
  linkActiveClass: "active",
  linkExactActiveClass: "ex-active",
  routes,
});

export default router;
